﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>欢迎登录后台管理系统</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="js/jquery.js"></script>
<script src="js/cloud.js" type="text/javascript"></script>

<script language="javascript">
	$(function(){
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
	$(window).resize(function(){  
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
    })  
});  
</script> 

</head>

<body style="background-color:#1c77ac; background-image:url(images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">



    <div id="mainBody">
      <div id="cloud1" class="cloud"></div>
      <div id="cloud2" class="cloud"></div>
    </div>  


<div class="logintop">    
    <span>欢迎登录后台管理界面平台</span>    
    <ul>
    <li><a href="#">回首页</a></li>
    <li><a href="#">帮助</a></li>
    <li><a href="#">关于</a></li>
    </ul>    
    </div>
    
    <div class="loginbody">
    
    <span class="systemlogo"></span> 
       
    <div class="loginbox">
    
    <ul>
    <li><input name="" type="text" class="loginuser" value="" id="account" /></li>
    <li><input name="" type="password" class="loginpwd" value="密码" id="password" /></li>
    <li><input name="" type="button" class="loginbtn" value="登录" onclick="subLogin()" /><label><input name="" type="checkbox" value="" checked="checked" />记住密码</label><label><a href="#">忘记密码？</a></label></li>
    </ul>
    
    
    </div>
    
    </div>
    
    
    
    <div class="loginbm">版权所有  2013  <a href="http://www.uimaker.com">uimaker.com</a>  仅供学习交流，勿用于任何商业用途</div>
	
    
</body>

</html>
<script type="text/javascript">
    function subLogin() {
        let account = document.getElementById("account").value; // 获取输入框的值
        let password = document.getElementById("password").value; // 获取输入框的值

        if (account === "") { // 比较输入框的值
            alert("请输入用户名");
            return false;
        }
        if (password === "") { // 比较输入框的值
            alert("请输入密码");
            return false;
        }

        $.ajax({
            type: "post",
            url: "login",
            data: { account: account, password: password }, // 传递输入框的值
            dataType: "text", // 放在对象中
            success: function(res) { // 正确的回调函数语法
                if ("y" === res) { // 使用正确的逻辑运算符
                    alert("登录成功");
                    localStorage.setItem("account", account);
                    window.location.href = "main.html";
                } else {
                    alert("登录失败");
                }
            }
        });
    }
</script>